package com.google.code.netcheckin.io;

public class Ascii {
	public static final byte V_NULL			= 0;
	public static final byte V_SOH			= 1; // start of head
	public static final byte V_STX			= 2; // start of text
	public static final byte V_ETX			= 3; // end of text
	public static final byte V_EOT			= 4; // end of tmit
	public static final byte V_ENQ			= 5; // enquiry
	public static final byte V_ACK			= 6; // acknowledge
	public static final byte V_BEL			= 7; // '\a' bell
	public static final byte V_BS			= 8; // '\b' backspace
	public static final byte V_HT			= 9; // '\t' h tab
	public static final byte V_LF			= 10;// '\n' new line
	public static final byte V_VT			= 11;// '\v' vert tab
	public static final byte V_NP			= 12;// '\f' form feed
	public static final byte V_CR			= 13;// '\r' carriage r
	public static final byte V_SO			= 14;// shift out
	public static final byte V_SI			= 15;// shift in
	public static final byte V_DLE			= 16;// data link esc
	public static final byte V_DC1			= 17;// device control
	public static final byte V_DC2			= 18;// device control
	public static final byte V_DC3			= 19;// device control
	public static final byte V_DC4			= 20;// device control
	public static final byte V_NAK			= 21;// negative ack
	public static final byte V_SYN			= 22;// synchron. idle
	public static final byte V_ETB 			= 23;
	public static final byte V_CAN			= 24;
	public static final byte V_EM			= 25;
	public static final byte V_SUB			= 26;
	public static final byte V_ESC			= 27;// ESC escape
	public static final byte V_FS			= 28;
	public static final byte V_GS			= 29;
	public static final byte V_RS			= 30;
	public static final byte V_US			= 31;
	public static final byte V_SPACE		= 32;// SPACE
	public static final byte V_SP			= 32;// SPACE
	public static final byte V_EXCLAMATION_MARK	= 33;
	public static final byte V_QUOTEDBL		= 34;
	public static final byte V_NUMBER_SIGN		= 35;
	public static final byte V_DOLLAR		= 36;
	public static final byte V_PERCENT		= 37;
	public static final byte V_AMPERSAND		= 38;
	public static final byte V_QUOTE		= 39;
	public static final byte V_LEFT_PARENTHESIS	= 40;
	public static final byte V_RIGHT_PARENTHESIS	= 41;
	public static final byte V_ASTERISK		= 42;
	public static final byte V_PLUS			= 43;
	public static final byte V_COMMA		= 44;
	public static final byte V_MINUS		= 45;
	public static final byte V_PERIOD		= 46;
	public static final byte V_SLASH 		= 47;
	public static final byte V_0			= 48;
	public static final byte V_1			= 49;
	public static final byte V_2			= 50;
	public static final byte V_3			= 51;
	public static final byte V_4			= 52;
	public static final byte V_5			= 53;
	public static final byte V_6			= 54;
	public static final byte V_7			= 55;
	public static final byte V_8			= 56;
	public static final byte V_9			= 57;
	public static final byte V_COLON		= 58;
	public static final byte V_SEMI_COLON		= 59;
	public static final byte V_LESS_THAN		= 60;
	public static final byte V_EQUALS		= 61;
	public static final byte V_GREATER_THAN		= 62;
	public static final byte V_QUESTION		= 63;
	public static final byte V_AT			= 64;
	public static final byte V_A			= 65;
	public static final byte V_B			= 66;
	public static final byte V_C			= 67;
	public static final byte V_D			= 68;
	public static final byte V_E			= 69;
	public static final byte V_F			= 70;
	public static final byte V_G			= 71;
	public static final byte V_H			= 72;
	public static final byte V_I			= 73;
	public static final byte V_J			= 74;
	public static final byte V_K			= 75;
	public static final byte V_L			= 76;
	public static final byte V_M			= 77;
	public static final byte V_N			= 78;
	public static final byte V_O			= 79;
	public static final byte V_P			= 80;
	public static final byte V_Q			= 81;
	public static final byte V_R			= 82;
	public static final byte V_S			= 83;
	public static final byte V_T			= 84;
	public static final byte V_U			= 85;
	public static final byte V_V			= 86;
	public static final byte V_W			= 87;
	public static final byte V_X			= 88;
	public static final byte V_Y			= 89;
	public static final byte V_Z			= 90;
	public static final byte V_OPEN_BRACKET		= 91;
	public static final byte V_BACK_SLASH		= 92;
	public static final byte V_CLOSE_BRACKET	= 93;
	public static final byte V_CIRCUMFLEX		= 94;
	public static final byte V_UNDERSCORE		= 95;
	public static final byte V_BACK_QUOTE		= 96;
	public static final byte V_a			= 97;
	public static final byte V_b			= 98;
	public static final byte V_c			= 99;
	public static final byte V_d			= 100;
	public static final byte V_e			= 101;
	public static final byte V_f			= 102;
	public static final byte V_g			= 103;
	public static final byte V_h			= 104;
	public static final byte V_i			= 105;
	public static final byte V_j			= 106;
	public static final byte V_k			= 107;
	public static final byte V_l			= 108;
	public static final byte V_m			= 109;
	public static final byte V_n			= 110;
	public static final byte V_o			= 111;
	public static final byte V_p			= 112;
	public static final byte V_q			= 113;
	public static final byte V_r			= 114;
	public static final byte V_s			= 115;
	public static final byte V_t			= 116;
	public static final byte V_u			= 117;
	public static final byte V_v			= 118;
	public static final byte V_w			= 119;
	public static final byte V_x			= 120;
	public static final byte V_y			= 121;
	public static final byte V_z			= 122;
	public static final byte V_BRACELEFT		= 123;
	public static final byte V_PIPE			= 124;
	public static final byte V_BRACERIGHT		= 125;
	public static final byte V_TILDE		= 126;
	public static final byte V_DEL			= 127;

		/**
		  * If the byte represents a digit, return the
		  * value of the digit that is represented.
		  * For example, the a value of 50 represents
		  * the digit 2, and the digitToInt(50) returns 2.
		  * If the value does not represent a digit, the result
		  * will be the value of the argument less V_0.
		  *
		*/

	public static final int digitToInt(final byte abyte) {
		return abyte - V_0;
	}

	public static final boolean isDigit(final byte abyte) {
		return abyte <= V_9 && abyte >= V_0;
	}

	public static final boolean isLetter(final byte abyte) {
		return isLowerCase(abyte) || isUpperCase(abyte);
	}

	public static final boolean isLowerCase(final byte abyte) {
		return abyte >= V_a && abyte <= V_z;
	}

	public static final boolean isUpperCase(final byte abyte) {
		return abyte >= V_A && abyte <= V_Z;
	}

	public static final boolean isWhiteSpace(final byte abyte) {
		return abyte == V_SP		// space
			|| abyte == V_LF	// line feed
			|| abyte == V_HT	// tab
			|| abyte == V_CR	// carriage return
			|| abyte == V_NP	// form feed (new page)
			|| abyte == V_VT;	// vertical tab
	}

	public static final byte toLowerCase(final byte achar) {
		return isUpperCase(achar)
			? (byte)(V_a + achar - V_A)
			: achar;
	}

		/**
		  * Return a byte array that is a lower case version
		  * of that provided. The original remains unmodified.
		  *
		*/

	public static final byte[] toLowerCase(final byte[] somechars) {
		final int ceil = somechars.length;
		final byte[] answer = new byte[ceil];
		for (int idx = 0; idx < ceil; idx ++) {
			answer[idx] = toLowerCase(somechars[idx]);
		}
		return answer;
	}

	public static final byte toUpperCase(final byte achar) {
		return isLowerCase(achar)
			? (byte)(V_A + achar - V_a)
			: achar;
	}

		/**
		  * Return a byte array that is an upper case version
		  * of that provided. The original remains unmodified.
		  *
		*/

	public static final byte[] toUpperCase(final byte[] somechars) {
		final int ceil = somechars.length;
		final byte[] answer = new byte[ceil];
		for (int idx = 0; idx < ceil; idx ++) {
			answer[idx] = toUpperCase(somechars[idx]);
		}
		return answer;
	}

}
